home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MPW Oberon 2.1168 / OInterfaces / Translation.mod < prev    next >
Encoding:
Text File  |  1995-08-10  |  11.8 KB  |  281 lines  |  [TEXT/MPS ]

  1. (*
  2.      File:        Translation.mod
  3.  
  4.      Contains:    Translation Manager (Macintosh Easy Open) Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs.applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. *)
  19.  
  20. (*$TAGS-*)
  21. (*$CALLING PASCAL*)
  22. MODULE Translation;
  23.  
  24. IMPORT SYSTEM, Types, Files, TranslationExtensions;
  25.  
  26. (* $PUSH*)
  27. (* $ALIGN MAC68K*)
  28. (* $LibExport+*)
  29.     
  30. TYPE
  31.     DocOpenMethod* = INTEGER;
  32.  
  33.  
  34. CONST
  35.     domCannot*                    = 0;
  36.     domNative*                    = 1;
  37.     domTranslateFirst*            = 2;
  38.     domWildcard*                    = 3;
  39.  
  40. (* 0L terminated array of OSTypes, or FileTypes*)
  41.     
  42. TYPE
  43.     TypesBlock* = ARRAY 64 (*ΔΔ[0..63]ΔΔ*) OF Types.OSType;
  44.  
  45.     TypesBlockPtr* = POINTER TO TypesBlock (*ΔΔ Types.OSType*);
  46.  
  47. (* Progress dialog resource AIFF.ID*)
  48.  
  49. CONST
  50.     kTranslationScrapProgressDialogID* = -16555;
  51.  
  52. (* block of data that describes how to translate*)
  53.  
  54. TYPE
  55.     FileTranslationSpec* = RECORD
  56.         componentSignature*:        Types.OSType;
  57.         translationSystemInfo*:    Types.Ptr;
  58.         src*:                    TranslationExtensions.FileTypeSpec;
  59.         dst*:                    TranslationExtensions.FileTypeSpec;
  60.     END;
  61.  
  62.     FileTranslationSpecArrayPtr* = POINTER TO FileTranslationSpec;
  63.  
  64. (*****************************************************************************************
  65. *   GetFileTypesThatAppCanNativelyOpen
  66. *  This routine returns a list of all FileTypes that an application can open by itself
  67. *  Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  68. *             appSignature        signature (creator) of application
  69. *             nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  70. *  Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  71. *)
  72.  
  73. PROCEDURE GetFileTypesThatAppCanNativelyOpen*(appVRefNumHint: INTEGER; appSignature: Types.OSType; VAR nativeTypes: TranslationExtensions.FileType): Types.OSErr;
  74.     (*$IF NOT GENERATINGCFM*)
  75.     INLINE PASCAL $701C, $ABFC;
  76.     (*$END*)
  77. (*****************************************************************************************
  78. *  ExtendFileTypeList
  79. *  This routine makes a new list of file types that can be translated into a type in the given list
  80. *  Used by StandardFile
  81. *  Enter:    originalTypeList        pointer to list of file types that can be opened
  82. *             numberOriginalTypes        number of file types in orgTypeList
  83. *              extendedTypeList        pointer to a buffer to be filled with file types
  84. *             numberExtendedTypes        max number of file types that can be put in extendedTypeList
  85. *  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  86. *             numberExtendedTypes        number of file types put in extendedTypeList
  87. *)
  88. PROCEDURE ExtendFileTypeList*((*CONST*)VAR originalTypeList: TranslationExtensions.FileType; numberOriginalTypes: INTEGER; VAR extendedTypeList: TranslationExtensions.FileType; VAR numberExtendedTypes: INTEGER): Types.OSErr;
  89.     (*$IF NOT GENERATINGCFM*)
  90.     INLINE PASCAL $7009, $ABFC;
  91.     (*$END*)
  92. (*****************************************************************************************
  93. *  This routine checks if a file can be opened by a particular application.
  94. *  If so, it returns if it needs to be translated first, and if so then how.
  95. *  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  96. *  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  97. *  Enter:    targetDocument        document to check if it can be opened
  98. *             appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  99. *             appSignature        signature (creator) of application to open doc
  100. *             nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  101. *             onlyNative            whether to consider if document can be translated before opening
  102. *             howToOpen            pointer to buffer in which to put how the document can be opened
  103. *             howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  104. *  Exit:    howToOpen            whether file needs to be translated to be read
  105. *             howToTranslate        if file can be translated, buffer filled in with how to translate
  106. *             returns                noErr, noPrefAppErr
  107. *)
  108. PROCEDURE CanDocBeOpened*((*CONST*)VAR targetDocument: Files.FSSpec; appVRefNumHint: INTEGER; appSignature: Types.OSType; (*CONST*)VAR nativeTypes: TranslationExtensions.FileType; onlyNative: BOOLEAN; VAR howToOpen: DocOpenMethod; VAR howToTranslate: FileTranslationSpec): Types.OSErr;
  109.     (*$IF NOT GENERATINGCFM*)
  110.     INLINE PASCAL $701E, $ABFC;
  111.     (*$END*)
  112. (*****************************************************************************************
  113. *  GetFileTranslationPaths
  114. *  This routine returns a list of all ways a translation can occure to or from a FileType.
  115. *  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  116. *  Enter:    srcDoc            source file or NULL for all matches
  117. *             dstDoc            destination FileType or NULL for all matches
  118. *             maxResultCount
  119. *             resultBuffer
  120. *  Exit:    number of paths
  121. *)
  122. PROCEDURE GetFileTranslationPaths*(VAR srcDocument: Files.FSSpec; dstDocType: TranslationExtensions.FileType; maxResultCount: INTEGER; resultBuffer: FileTranslationSpecArrayPtr): INTEGER;
  123.     (*$IF NOT GENERATINGCFM*)
  124.     INLINE PASCAL $7038, $ABFC;
  125.     (*$END*)
  126. (*****************************************************************************************
  127. *  GetPathFromTranslationDialog
  128. *  This routine, with a given document, application, and a passed typelist will display the
  129. *  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  130. *  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  131. *  The routine returns the translation path information.
  132. *  Enter:    theDocument            Files.FSSpec to document to open
  133. *             theApplication        Files.FSSpec to application to open document
  134. *             typeList            Nil terminated list of FileType's (e.g. StandardFile.SFTypeList-like) of types
  135. *                                 you would like the documented translated to.  Order most perferred
  136. *                                 to least.
  137. *  Exit:    howToOpen            Translation method needed to open document
  138. *             howToTranslate        Translation specification
  139. *             returns                Any errors that might occur.
  140. *)
  141. PROCEDURE GetPathFromTranslationDialog*((*CONST*)VAR theDocument: Files.FSSpec; (*CONST*)VAR theApplication: Files.FSSpec; typeList: TypesBlockPtr; VAR howToOpen: DocOpenMethod; VAR howToTranslate: FileTranslationSpec): Types.OSErr;
  142.     (*$IF NOT GENERATINGCFM*)
  143.     INLINE PASCAL $7037, $ABFC;
  144.     (*$END*)
  145. (*****************************************************************************************
  146. *   TranslateFile
  147. *  This routine reads a file of one format and writes it to another file in another format. 
  148. *  The information on how to translated is generated by the routine CanDocBeOpened.
  149. *  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  150. *  The destination file must not exist.  It is created by this routine.  
  151. *  Enter:    sourceDocument            input file to translate
  152. *             destinationDocument        output file of translation
  153. *             howToTranslate            pointer to info on how to translate
  154. *  Exit:    returns                    noErr, badTranslationSpecErr 
  155. *)
  156. PROCEDURE TranslateFile*((*CONST*)VAR sourceDocument: Files.FSSpec; (*CONST*)VAR destinationDocument: Files.FSSpec; (*CONST*)VAR howToTranslate: FileTranslationSpec): Types.OSErr;
  157.     (*$IF NOT GENERATINGCFM*)
  158.     INLINE PASCAL $700C, $ABFC;
  159.     (*$END*)
  160. (*****************************************************************************************
  161. *   GetDocumentKindString
  162. *  This routine returns the string the Finder should show for the "kind" of a document
  163. *  in the GetInfo window and in the kind column of a list view.  
  164. *  Enter:    docVRefNum        The volume containing the document
  165. *             docType            The catInfo.fdType of the document
  166. *             docCreator        The catInfo.fdCreator of the document
  167. *             kindString        pointer to where to return the string
  168. *  Exit:    kindString        pascal string.  Ex: "\pSurfCalc spreadsheet"
  169. *             returns            noErr, or afpItemNoFound if kind could not be determined
  170. *)
  171. PROCEDURE GetDocumentKindString*(docVRefNum: INTEGER; docType: Types.OSType; docCreator: Types.OSType; VAR kindString: Types.Str63): Types.OSErr;
  172.     (*$IF NOT GENERATINGCFM*)
  173.     INLINE PASCAL $7016, $ABFC;
  174.     (*$END*)
  175. (*****************************************************************************************
  176. *  GetTranslationExtensionName
  177. *  This routine returns the translation system name from a specified TranslationSpec
  178. *  Enter:    translationMethod    The translation path to get the translation name from
  179. *  Exit:    extensionName        The name of the translation system
  180. *             returns                Any errors that might occur
  181. *)
  182. PROCEDURE GetTranslationExtensionName*((*CONST*)VAR translationMethod: FileTranslationSpec; VAR extensionName: Types.Str31): Types.OSErr;
  183.     (*$IF NOT GENERATINGCFM*)
  184.     INLINE PASCAL $7036, $ABFC;
  185.     (*$END*)
  186. (*****************************************************************************************
  187. *  GetScrapDataProcPtr
  188. *  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  189. *  get the data to be translated.  The first call TranslateScrap will make to this is to
  190. *  ask for the LONG("fmts") data.  That is a special.   You should resize and fill in the handle
  191. *  with a list all the formats that you have available to be translated, and the length of each.
  192. *  (See I.M. VI 4-23 for details of LONG("fmts")).  It will then be called again asking for one of  
  193. *  the formats that LONG("fmts") list said was available.
  194. *  Enter:    requestedFormat            Format of data that TranslateScrap needs.
  195. *             dataH                    Types.Handle in which to put the requested data
  196. *             srcDataGetterRefCon        Extra parameter for you passed to TranslateScrap
  197. *             
  198. *  Exit:    dataH                    Types.Handle is resized and filled with data in requested format
  199. *)
  200. TYPE
  201.     GetScrapDataProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (requestedFormat: TranslationExtensions.ScrapType; dataH: Types.Handle; srcDataGetterRefCon: (*ΔΔUNIVΔΔ*) Types.Ptr): Types.OSErr;
  202.     GetScrapDataUPP* = Types.UniversalProcPtr;
  203.  
  204. CONST
  205.     uppGetScrapDataProcInfo* = $00000FE0; (* PROCEDURE (4 byte param, 4 byte param, 4 byte param): 2 byte result; *)
  206.  
  207. PROCEDURE NewGetScrapDataProc*(userRoutine: GetScrapDataProcPtr): GetScrapDataUPP;
  208.     (*$IF NOT GENERATINGCFM *)
  209.     INLINE PASCAL $2E9F;
  210.     (*$END*)
  211.  
  212. PROCEDURE CallGetScrapDataProc*(requestedFormat: TranslationExtensions.ScrapType; dataH: Types.Handle; srcDataGetterRefCon: (*ΔΔUNIVΔΔ*) Types.Ptr; userRoutine: GetScrapDataUPP): Types.OSErr;
  213.     (*$IF NOT GENERATINGCFM*)
  214.     INLINE PASCAL $205F, $4E90;
  215.     (*$END*)
  216.     
  217. TYPE
  218.     GetScrapData* = GetScrapDataUPP;
  219.  
  220. (*****************************************************************************************
  221. *  TranslateScrap
  222. *  This routine resizes the destination handle and fills it with data of the requested format.
  223. *  The data is generated by translated one or more source formats of data supplied by
  224. *  the procedure srcDataGetter*.  
  225. *  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  226. *  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  227. *  Enter:    sourceDataGetter            Pointer to routine that can get src data
  228. *             sourceDataGetterRefCon        Extra parameter for dataGetter
  229. *             destinationFormat            Format of data desired
  230. *             destinationData                Types.Handle in which to store translated data
  231. *             
  232. *  Exit:    dstData                        Types.Handle is resized and filled with data in requested format
  233. *)
  234.  
  235. PROCEDURE TranslateScrap*(sourceDataGetter: GetScrapData; sourceDataGetterRefCon: (*ΔΔUNIVΔΔ*) Types.Ptr; destinationFormat: TranslationExtensions.ScrapType; destinationData: Types.Handle; progressDialogID: INTEGER): Types.OSErr;
  236.     (*$IF NOT GENERATINGCFM*)
  237.     INLINE PASCAL $700E, $ABFC;
  238.     (*$END*)
  239.  
  240. (* $ALIGN RESET*)
  241. (* $POP*)
  242.  
  243.  END Translation.
  244. (*$END*)
  245.